using System;

namespace SG3L_RAG.Domain.Entities
{
    public class Statistics : EntityBase
    {
        public string StatType { get; private set; } = string.Empty;
        public int StatValue { get; private set; }

        // EF Core 需要的无参构造函数
        public Statistics() { }

        // 业务构造函数
        private Statistics(string statType, int statValue)
        {
            StatType = statType;
            StatValue = statValue;
            CreatedAt = DateTime.UtcNow;
        }

        // 工厂方法
        public static Statistics Create(string statType, int statValue)
        {
            return new Statistics(statType, statValue);
        }

        public bool IsToday() => CreatedAt.Date == DateTime.Today;

        // 判断统计类型
        public bool IsDocumentStat() => StatType == "document";
        public bool IsUserStat() => StatType == "user";
        public bool IsQnAStat() => StatType == "qna";

        // 生成统计数据（示例）
        public static Statistics CreateDocumentStat(int value)
        {
            return Statistics.Create("document", value);
        }
        public static Statistics CreateUserStat(int value)
        {
            return Statistics.Create("user", value);
        }
        public static Statistics CreateQnAStat(int value)
        {
            return Statistics.Create("qna", value);
        }
    }
}
